//
//@File    :	8.1_inline.cpp
//@Time    :	2021/08/14 19:49:35
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	using an inline function
//

//内联函数inline,直接使用相应的函数代码替换函数调用
//优点:运行速度比常规函数稍快
//缺点:占用更多内存
//适用于短小的函数

#include <iostream>

using namespace std;
inline double square(double x){return x*x;}
int main()
{
    double a,b;
    double c=13.0;

    a=square(5.0);
    b=square(4.5+7.5);
    cout<<"a = "<<a<<",b = "<<b<<"\n";
    cout<<"c = "<<c;
    cout<<",c squareed = "<<square(c++)<<"\n";
    cout<<"Now c = "<<c<<"\n";
    system("pause");
    return 0;
}